package com.runen.infinitemovement.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.runen.infinitemovement.R;
import com.runen.infinitemovement.model.entity.MyDynamicListEntity;
import com.runen.infinitemovement.tool.GlideUtils;
import com.runen.infinitemovement.widget.imageview.RoundedCornersImage;
import com.runen.rxnetlibrary.utils.TimeUtil;

import java.util.List;

public class DynamicStateNotificationAdapter extends BaseQuickAdapter<MyDynamicListEntity.DataBean, BaseViewHolder> implements LoadMoreModule {
    private Context context;
    private int flag;

    public DynamicStateNotificationAdapter(Context context, int flag) {
        super(R.layout.item_dynamic_state_notification);
        this.context = context;
        this.flag = flag;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MyDynamicListEntity.DataBean item) {
        RoundedCornersImage rci_user_header = helper.getView(R.id.rci_user_header);
        helper.setText(R.id.tv_user_name, item.userName);
        TextView tv_comment_info = helper.getView(R.id.tv_comment_info);
        TextView tv_msg_type = helper.getView(R.id.tv_msg_type);
        GlideUtils.loadImage(context, item.headImage + "?x-oss-process=image/resize,m_fill,w_144,h_144", rci_user_header);
        tv_comment_info.setText(item.content);
        helper.setText(R.id.tv_time, TimeUtil.converFromSecondTime(TimeUtil.getDateTimeToLong(TimeUtil.dealDateFormat1(item.createTime))));
        switch (flag) {
            case 0:
                tv_comment_info.setVisibility(View.VISIBLE);
                tv_msg_type.setText("评论了你");
                break;
            case 1:
                tv_comment_info.setVisibility(View.GONE);
                tv_msg_type.setText("赞了你");
                break;
            case 2:
                tv_comment_info.setVisibility(View.GONE);
                tv_msg_type.setText("关注了你");
                break;
        }
    }
}
